package com.itheima.advantagesup.dto;

import com.alibaba.fastjson.JSON;
import com.itheima.advantagesup.entity.SysUser;
import com.itheima.advantagesup.vo.UserInfoVO;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

@Data
public class UserDTO {
    private String id;
    private String name;
    private String login_name;
    private String password;
    private String email;
    private String phone;
    private List<String> role_id;
    private Integer status;

    public SysUser transformSysUser(){
        SysUser sysUser = new SysUser();
        sysUser.setId(this.id);
        sysUser.setLoginName(this.login_name);
        sysUser.setPassword(this.password);
        sysUser.setName(this.name);
        sysUser.setEmail(this.email);
        sysUser.setPhone(this.phone);
        //sysUser.setUpdate_date(LocalDateTime.now());

        String roleId = JSON.toJSONString(this.role_id);
        sysUser.setRoleId(roleId);

        sysUser.setStatus(this.status);

        return sysUser;

        /*UserInfoVO sysUser = new UserInfoVO();
        //userInfoVO.setId(this.id);
        sysUser.setLoginName(this.login_name);
        sysUser.setName(this.name);
        sysUser.setPassword(this.password);
        sysUser.setEmail(this.email);
        sysUser.setRoleId(this.role_id);
        return sysUser;*/

    }

}
